import javax.swing.text.DefaultHighlighter.DefaultHighlightPainter;

/**
 * The abstraction of each sub-file
 * 
 * @author U097023U
 *
 */
public class SmallDocument 
{

	/**
	 * the sub-file name
	 */
	public String docName;
	
	/**
	 * index of the first paragraph of this sub-file
	 * index start from 0
	 */
	public int firstParaIndex;
	
	/**
	 * number of paras this sub-file contains
	 */
	public int numberOfParas;
	
	/**
	 * whether this sub-file has been modified since last saving action
	 */
	public boolean isModified;
	
	/**
	 * the locking status of this sub-file
	 * 0: not being locked by anyone
	 * 1: locked by me
	 * 2: locked by another author
	 */
	public int lockingStatus;

	public int stepsBeforeLock = 0;
	
	/**
	 * index of this sub-file in current editor
	 */
	public int sdIndex; // Small document index in the Editor.
	
	public Object highlight = null;
	public DefaultHighlightPainter hlPainter = null;
	
	public SmallDocument(){
		
	}
		
	public SmallDocument(String name){
		
		this(name, 0, 1, false, 0, 0);
		
	}
	
	public SmallDocument(String name, int numParas){
		
		this(name, 0, numParas, false, 0, 0);
	}
	
	public SmallDocument(String name, int firstPara, int numParas){
		
		this(name, firstPara, numParas, false, 0, 0);
	}
	
	/**
	 * the real constructor
	 * @param name
	 * @param firstPara
	 * @param numParas
	 * @param modified
	 * @param locking
	 * @param index
	 */
	public SmallDocument(String name, int firstPara, int numParas, boolean modified, int locking, int index){
		
		this.docName = name;
		this.firstParaIndex = firstPara;
		this.numberOfParas = numParas;
		this.isModified = modified;
		this.lockingStatus = locking;
		this.sdIndex = index;
	}
	
	public int getDocumentLength(){
		return 0;		// get the length of the document, not implemented yet
	}
	
	public void setDocName(String name){
		this.docName = name;
	}
	
	public String toString ()
	{
		String returnString = "Filename: " + docName + ", start: " + firstParaIndex + 
			", number of paras: " + numberOfParas + ", isModified: " + isModified + 
			", lockingStatus: " + lockingStatus + ", index: " + sdIndex + "\n";
		
		return returnString;
	}
}
